﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Chocolate
{
    partial class ChocHelper
    {
        private void FireGameChanges()
        {
            FirePropertyChanged("Players");
            FirePropertyChanged("TgdbRating");
            FirePropertyChanged("ProductionYear");
            FirePropertyChanged("EsrbRating");
            FirePropertyChanged("Company");
            FirePropertyChanged("ConsoleReleaseYear");
            FirePropertyChanged("CpuBits");
            FirePropertyChanged("GpuBits");
        }

        private int GetDynamicPropertyAsInt(string PropertyName)
        {
            try
            {
                return Convert.ToInt32(CurrentItem.DynamicProperties[PropertyName]);
            }
            catch (Exception)
            {
                return 0;
            }
        }

        private Single GetDynamicPropertyAsSingle(string PropertyName)
        {
            try
            {
                return Convert.ToSingle(CurrentItem.DynamicProperties[PropertyName]);
            }
            catch
            {
                return 0;
            }
        }

        public string Players
        {
            get
            {

                string players = GetDynamicProperty("Players");

                if (players != null)
                {
                    return players;

                }
                return "";

            }

        }


        public Single TgdbRating
        {
            get
            {

                Single rating = GetDynamicPropertyAsSingle("TgdbRating");

                if (rating > 0)
                {
                    return rating;
                }
                return 0;

            }

        }


        public string EsrbRating
        {
            get
            {
                string rating = GetDynamicProperty("EsrbRating");

                if (rating != null)
                {
                    return rating;
                }

                return "";
            }
        }

        public string ConsoleReleaseYear
        {
            get
            {
                int year = GetDynamicPropertyAsInt("ReleaseYear");

                if (year != 0)
                {
                    return year.ToString();
                }

                return "";
            }
        }

        public string Company
        {
            get
            {
                string company = GetDynamicProperty("Manufacturer");

                if (company != null)
                {
                    return company;
                }

                return "";
            }
        }

        public string CpuBits
        {
            get
            {
                string cpu = GetDynamicProperty("CPU");

                if (cpu != null)
                {
                    return cpu;
                }

                return "";
            }
        }

        public string GpuBits
        {
            get
            {
                string gpu = GetDynamicProperty("GPU");

                if (gpu != null)
                {
                    return gpu;
                }

                return "";
            }
        }

    }
}